package com.liwei.vip.mall.goods.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liwei.vip.mall.goods.mapper.CategoryMapper;
import com.liwei.vip.mall.goods.model.Category;
import com.liwei.vip.mall.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//一级导航，显示导航数据
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 根据分类父ID查询所有子类 相应的parent_id
     *
     * @param pid
     */
    @Override
    public List<Category> findByParentId(Integer pid) {

        //条件分装对象
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", pid);

        return categoryMapper.selectList(queryWrapper);
    }
}
